package com.sihai.ehr.web.pojo;

import com.sihai.ehr.model.sys.DispersionPatternEnum;

/**
 * 强制性分布设置实体Bean类
 * <p>
 * 表现形式如下：
 * </p>
 * 
 * <pre>
 * 	特优 	95-100分 		 5% 		1人 
 * 	优等 	85-94.9分  	20%		5人 
 * 	甲等 	75-84.9分 	50%		12人 
 * 	乙上 	65-74.9分 	20%		5人 
 * 	乙等 	0-64.9分 		5%		1人
 * </pre>
 * 
 * @author Henry
 * 
 */
public class ExamQualCoerceSetPojo {

	private Long id;
	/** 组织机构ID */
	private Long organizationId;
	/** 考核类型 */
	private DispersionPatternEnum type;
	/** 绩等名称 */
	private String name;

	/** 分数下限 |最低分 */
	private Float scoreStart;

	/** 分数上限|最高分 */
	private Float scoreEnd;

	/** 人数比率 */
	private Float percentage;

	/** 实际人数比率 */
	private Float actualPercentage;

	/** 分配 人数 */
	private int number;

	/** 实际人数 */
	private int actualNumber;

	/** 差额人数 */
	private int balanceNumber;

	/** 原始需要分配总人数 */
	private int rawTotalNumber;
	/** 实际打分的人数 */
	private int actualTotalNumber;

	public ExamQualCoerceSetPojo() {

	}

	public ExamQualCoerceSetPojo(Long id, Long organizationId, String type,
			String name, Float scoreStart, Float scoreEnd, Float percentage,
			int number, int actualNumber, int rawTotalNumber,
			int actualTotalNumber) {
		this.id = id;
		this.organizationId = organizationId;
		this.type = type == null ? DispersionPatternEnum.no_distribution
				: DispersionPatternEnum.valueOf(type);
		this.name = name;
		this.scoreStart = scoreStart;
		this.scoreEnd = scoreEnd;
		this.rawTotalNumber = rawTotalNumber;
		this.actualTotalNumber = actualTotalNumber;
		this.actualNumber = actualNumber;
		if (this.type == DispersionPatternEnum.percentage) {
			this.percentage = percentage;
			this.number = (int) Math.floor(this.percentage * rawTotalNumber);
			this.actualPercentage = actualTotalNumber <= 0 ? 0
					: (float) actualNumber / actualTotalNumber;
			this.balanceNumber = actualNumber - number;
		} else if (this.type == DispersionPatternEnum.custom_field) {
			this.number = number;
			this.percentage = rawTotalNumber != 0 ? (float) this.number
					/ rawTotalNumber : 0;
			this.actualPercentage = actualTotalNumber == 0 ? 0
					: (float) actualNumber / actualTotalNumber;
			this.balanceNumber = actualNumber - number;
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getOrganizationId() {
		return organizationId;
	}

	public void setOrganizationId(Long organizationId) {
		this.organizationId = organizationId;
	}

	public DispersionPatternEnum getType() {
		return type;
	}

	public void setType(DispersionPatternEnum type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Float getScoreStart() {
		return scoreStart;
	}

	public void setScoreStart(Float scoreStart) {
		this.scoreStart = scoreStart;
	}

	public Float getScoreEnd() {
		return scoreEnd;
	}

	public void setScoreEnd(Float scoreEnd) {
		this.scoreEnd = scoreEnd;
	}

	public Float getPercentage() {
		return percentage;
	}

	public void setPercentage(Float percentage) {
		this.percentage = percentage;
	}

	public Float getActualPercentage() {
		return actualPercentage;
	}

	public void setActualPercentage(Float actualPercentage) {
		this.actualPercentage = actualPercentage;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public int getActualNumber() {
		return actualNumber;
	}

	public void setActualNumber(int actualNumber) {
		this.actualNumber = actualNumber;
	}

	public int getBalanceNumber() {
		return balanceNumber;
	}

	public void setBalanceNumber(int balanceNumber) {
		this.balanceNumber = balanceNumber;
	}

	public int getRawTotalNumber() {
		return rawTotalNumber;
	}

	public void setRawTotalNumber(int rawTotalNumber) {
		this.rawTotalNumber = rawTotalNumber;
	}

	public int getActualTotalNumber() {
		return actualTotalNumber;
	}

	public void setActualTotalNumber(int actualTotalNumber) {
		this.actualTotalNumber = actualTotalNumber;
	}
}
